#include <iostream>

// 抽象产品
class Car
{
public:
    virtual void show() = 0;
};

// 具体产品
// 宝马
class BMW : public Car
{
public:
    BMW(int a) {}
    void show()
    {
        std::cout << "一辆宝马\n";
    }
};

// 奔驰
class Benz : public Car
{
public:
    Benz(double b) {}
    void show()
    {
        std::cout << "一辆奔驰\n";
    }
};

// 奥迪
class Audi : public Car
{
public:
    Audi(char c) {}
    void show()
    {
        std::cout << "一辆奥迪\n";
    }
};

// 工厂类：负责生产具体的产品
class Factory
{
public:
    Car *CreateBMW()
    {
        return new BMW(1);
    }

    Car *CreateBenz()
    {
        return new Benz(3.14);
    }

    Car *CreateAudi()
    {
        return new Audi('c');
    }
};

int main()
{
    // Car *c = new Benz; // 不再关心对象构建的方式
    Factory f;
    Car *c = f.CreateBenz();
    c->show();
    return 0;
}